import { getInterviewRecord, getInterviewResult } from '@/services/myRecruit/candidate';

export default {
    namespace: 'filterRecord',
    state: {
        interviewList: [], // 候选人详情中面试记录列表
        interviewResult: [] // 面试结果
    },
    effects: {
        // 查询候选人筛选/面试记录
        *fetchInterviewRecord({ payload }, { call, put }) {
            const result = yield call(getInterviewRecord, payload);
            if (result && result.code === 10000) {
                yield put({
                    type: 'save',
                    payload: {
                        interviewList: result.data
                    }
                });
            }
        },
        // 查询面试结果
        *fetchInterviewResult({ payload }, { call, put }) {
            const result = yield call(getInterviewResult, payload);
            if (result && result.code === 10000) {
                yield put({
                    type: 'save',
                    payload: {
                        interviewResult: result.data
                    }
                });
            }
        }
    },
    reducers: {
        save(state, { payload }) {
            return {
                ...state,
                ...payload
            };
        }
    }
};
